{extend name="_layout/default" /}

{block name="header"}
<style>
    a{color: inherit;text-decoration: none}
    .cursor-pointer{cursor:pointer;}
    .tag-active {
        color: #FFFFFF!important;
        background-color: #3ab394!important;
    }
</style>

{/block}


{block name="main"}
<div class="mdui-container">
    <div class="mdui-row">
        <div class="mdui-col-xs-12 mdui-col-sm-9 mdui-p-l-1">
            <div class="tags">
                <form>
                    <div>
                        {volist name="tags" id="tag"}
                        <div class="mdui-chip {$query['tag'] == $tag ? 'tag-active' : ''} tag">
                            <span class="mdui-chip-title">{$tag}</span>
                        </div>
                        {/volist}
                        <input name="tag" value="{$query.tag}" id="tag-input" type="hidden"/>
                    </div>
                    <div class="mdui-divider-inset mdui-m-l-0 mdui-m-t-1 mdui-m-b-1"></div>
                    <div style="padding-left: 5px">
                        {volist name="sorts" id="sort"}
                        <label class="mdui-radio  mdui-m-r-1 mdui-p-l-3">
                            <input type="radio" name="sort" value="{$key}" class="" {$query["sort"] == $key ? 'checked' : ''}/>
                            <i class="mdui-radio-icon"></i>
                            {$sort}
                        </label>
                        {/volist}
                        <label class="mdui-checkbox mdui-m-r-1 mdui-p-l-3">
                            <input name="playable" value="1" type="checkbox" {$query["playable"] ? 'checked' : ''}/>
                            <i class="mdui-checkbox-icon"></i>
                            可在线播放
                        </label>
                    </div>
                </form>
                <div id="films">
                    {volist name="films" id="film"}
                    <div class="mdui-card" style="float: left;margin: 10px;width: 160px">
                        <!-- 卡片的媒体内容，可以包含图片、视频等媒体内容，以及标题、副标题 -->
                        <div class="mdui-card-media" style="height: 180px;overflow: hidden;">
                            <a href="{:url('/hot/' . $film['id'])}" target="_blank" title="{$film.title}">
                                <img src="{:url('/bridge/douban')}?url={$film.cover}&id={$film.id}" alt="{$film.title}" title="{$film.title}" style="width: 100%;"/>
                            </a>
                        </div>
                        <div class="mdui-card-content mdui-p-b-0 mdui-list-item-one-line" style="padding-top: 10px">
                            <a href="{:url('/hot/' . $film['id'])}" target="_blank" title="{$film.title}">{$film.title}</a>
                        </div>
                        <div class="mdui-card-content mdui-p-t-0">
                            <div style="float: left;font-size: 10px">
                                评分：<span>{$film.rate}</span>
                            </div>

                            <div style="float: right;font-size: 10px;color: #1ab394">
                                {if $film.playable}
                                <a href="{:url('/hot/' . $film['id'])}" target="_blank" title="{$film.title}">[可播放]</a>
                                {elseif $film.is_new/}
                                [新]
                                {/if}
                            </div>
                        </div>
                    </div>
                    {/volist}
                </div>
                <div class="mdui-shadow-1 cursor-pointer" id="load-more" style="clear: both;padding: 6px;background-color: #fdfdfd0d;text-align: center;border-radius: 5px;">
                    加载更多
                </div>
                <div class="mdui-progress" id="load-ing" style="display: none">
                    <div class="mdui-progress-indeterminate"></div>
                </div>
            </div>
        </div>
        <div class="mdui-col-xs-12 mdui-col-sm-3">
            {notempty name="chart.week"}
            <div>
                <h5 style="margin-top: 4px">本周口碑榜</h5>
                <ul class="mdui-list mdui-list-dense">
                    <li class="mdui-divider-inset mdui-m-y-0 mdui-m-l-0"></li>
                    {volist name="chart.week" id="vo"}
                    <li class="mdui-list-item mdui-ripple">
                        <div class="mdui-list-item-content">
                            <div class="mdui-list-item-title mdui-list-item-one-line">
                                <a href="{:url('/hot/' . $vo['id'])}" target="_blank" title="{$vo.title}">{$key+1}. &nbsp;{$vo.title}</a>
                            </div>
                        </div>
                    </li>
                    <li class="mdui-divider-inset mdui-m-y-0 mdui-m-l-0"></li>
                    {/volist}
                </ul>
            </div>
            {/notempty}

            {notempty name="chart.north_america"}
            <div>
                <h5 style="margin-bottom: 10px">北美票房榜</h5>
                <ul class="mdui-list mdui-list-dense">
                    <li class="mdui-divider-inset mdui-m-y-0 mdui-m-l-0"></li>
                    {volist name="chart.north_america" id="vo"}
                    <li class="mdui-list-item mdui-ripple">
                        <div class="mdui-list-item-content">
                            <div class="mdui-list-item-title mdui-list-item-one-line">
                                <a href="{:url('/hot/' . $vo['id'])}" target="_blank" title="{$vo.title}">{$key+1}. &nbsp;{$vo.title}</a>
                            </div>
                        </div>
                    </li>
                    <li class="mdui-divider-inset mdui-m-y-0 mdui-m-l-0"></li>
                    {/volist}
                </ul>
            </div>
            {/notempty}
        </div>
    </div>
</div>
{/block}


{block name="footer"}
<script>
    let $$ = mdui.JQ;
    $$(function () {
        let $$searchForm = $$('form'), start = 0;
        $$('[name="sort"]').on('click', function () {
            $$searchForm[0].submit();
        });
        $$('[name="playable"]').on('click', function () {
            $$searchForm[0].submit();
        });
        $$('.tag').on('click', function () {
            let tag = $$(this).text().trim();
            $$('#tag-input').val(tag);
            $$searchForm[0].submit();
        });
        
        $$('#load-more').on('click', function () {
            start += 20;
            let params = $$searchForm.serialize();
            $$.ajax({
                method: 'POST',
                url: '{:url("/hot/mlist")}?' + params + '&start=' + start,
                dataType:'text',
                success: function (data) {
                    data = JSON.parse(data)
                    if (data.length > 0) {
                        $$('#films').append(data);
                    } else {
                        $$('#load-more').remove();
                    }
                },
                beforeSend:function () {
                    $$('#load-more').hide();
                    $$('#load-ing').show();
                },
                complete:function () {
                    $$('#load-more').show();
                    $$('#load-ing').hide();
                }
            });
        });
    });

</script>
{/block}